import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react-swc'
import path from 'path'

// https://vite.dev/config/
export default defineConfig(({ mode }) => {
  //const env = loadEnv(mode, process.cwd())
  
  return {
    plugins: [
      react(), // 默认配置
    ],
    resolve:{
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    },
    server: {
      port: 5173,
      host: true,
      open: true
    },
    build: {
      outDir: 'dist',
      sourcemap: true,
    },
    // server: {
    //   proxy: {
    //     '/api': {
    //       target: env.VITE_API_BASE_URL,
    //       changeOrigin: true,
    //       rewrite: (path) => path.replace(/^\/api/, '')
    //     }
    //   }
    // }
  }
})
